//2009/08/18 21:23:37
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class RectangleGroups
{
public:
    string maximalIndexed(vector <string> rec)
    {
		int mmax = -1;
		char cdx;
		for(char ch='A'; ch<='Z'; ch++) v[ch] = -1;
		for(int i=0; i<rec.size(); i++)
		{
			stringstream sm(rec[i]);
			int a,b; char c;
			sm >> c >> a >> b;
			v[c] = v[c]==-1? a*b : v[c]+a*b;
		}
		for(char ch='A'; ch<='Z'; ch++) 
		{
			if(v[ch] > mmax || mmax == -1)
			{
				mmax = v[ch];
				cdx = ch;
			}
		}
		stringstream s;
		s << cdx << " " << mmax;
		return s.str();
    }
private:
    map<char, int> v;
};
